package com.zm.se.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        HandlerInterceptor interceptor=new LoginInterceptor();
        List<String> patterns=new ArrayList<>();
        patterns.add("/web/register.html");
        patterns.add("/users/register");
        patterns.add("/web/login.html");
        patterns.add("/users/login");
        patterns.add("/web/hide.html");
        patterns.add("/users/uploademp");
        patterns.add("/static/**");
        patterns.add("/static/css/**");
        patterns.add("/static/image/**");
        patterns.add("/static/bootstrap3/**");
        registry.addInterceptor(interceptor).addPathPatterns("/**").excludePathPatterns(patterns);
    }

}
